package Adaptadores;

import java.util.List;

import Clases.Contacto;
import com.example.tdam_2013_g11.R;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

public class ContactoListaAdapter extends ArrayAdapter<Contacto>{
	
	int resource;
	Context context;	
	
	public ContactoListaAdapter(Context context, int resources, List<Contacto> items){
		super(context,resources,items);
		this.resource = resources;
	}
	
	@Override
    public View getView(int position, View convertView, ViewGroup parent)
    {
		
        LinearLayout productView;
        Contacto contacto = getItem(position);
        if(convertView == null)
        {
        	productView = new LinearLayout(getContext());
            String inflater = Context.LAYOUT_INFLATER_SERVICE;
            LayoutInflater vi;
            vi = (LayoutInflater)getContext().getSystemService(inflater);
            vi.inflate(resource, productView, true);
        }
        else
        {
        	productView = (LinearLayout) convertView;
        }
        
        ImageView imagen = (ImageView)productView.findViewById(R.id.imageView_imagen);
        TextView nombre =(TextView)productView.findViewById(R.id.textView_info_nombreContacto);
        TextView descripcion =(TextView)productView.findViewById(R.id.textView_descripcionContacto);
        
        nombre.setText(contacto.getNombre());
        descripcion.setText("");
        return productView;
    }
}
